package com.qf.service.impl;

import com.qf.dao.LikeDao;
import com.qf.entity.Like;
import com.qf.service.LikeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author chen
 * @version 1.0
 * @date 2019/10/24 11:34
 */
@Service
public class LikeServiceImpl implements LikeService {
    @Resource
    private LikeDao likeDao;
    @Override
    public int likeIt(Integer showId, int userid) {
        Like like= likeDao.findByShowidAndUserId(showId,userid);

        if (like!=null&&like.getStatus()==1){
            likeDao.update(showId,userid,0);
            return 0;
        }else if (like!=null&&like.getStatus()==0){
            likeDao.update(showId,userid,1);
            return 1;
        }
        int i1= likeDao.likeIt(showId, userid);
        return i1;
    }
}
